package com.atguigu.springboot.entity;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @author : leimingchao
 * @date Date : 2021年10月17日 13:25
 */
//使用JPA注解配置映射关系
// 告诉JPA这是一个实体类(和数据表映射的类)
@Entity
//@Table来指定和哪个数据表对应；如果省略，默认表名就是类名小写user
@Table(name = "tbl_user")
public class User implements Serializable {

    private static final long serialVersionUID = 1884568257825893109L;

    //这是一个主键
    @Id
    //自增主键
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    //这是和数据表对应的一个列
    @Column(name = "last_name",length = 50)
    private String lastName;

    //省略，默认列名就是属性名
    @Column
    private String email;

    public User() {
    }

    public User(Integer id, String lastName, String email) {
        this.id = id;
        this.lastName = lastName;
        this.email = email;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", lastName='" + lastName + '\'' +
                ", email='" + email + '\'' +
                '}';
    }
}
